package com.movie.ticket.sale.bossassembly.common;

import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

/**
 * @BelongsProject: movie-zuul
 * @BelongsPackage: com.movie.ticket.sale.moviezuul.filter
 * @Author: lyl
 * @CreateTime: 2020-12-15 11:39
 * @Description:
 */
@Component
public class Resolver {

    //获取前端传过来得到的token
    public static Integer getId(){
        //获取请求对象
        ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        HttpServletRequest request = servletRequestAttributes.getRequest();
        int id=Integer.parseInt(request.getHeader("id"));


        return id;
    }
        public static String getTel(){
        //获取请求对象
            ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
            HttpServletRequest request = servletRequestAttributes.getRequest();
            String tel = request.getHeader("tel");


        return tel;
    }
    public static Integer getRole(){
        //获取请求对象
        ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        HttpServletRequest request = servletRequestAttributes.getRequest();
        Integer role = Integer.parseInt(request.getHeader("role"));
        return role;
    }
}
